package com.ruoyi.zhgd.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.zhgd.domain.NAsphaltData;
import com.ruoyi.zhgd.service.NAsphaltCommonService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 沥青通用控制器
 *
 * @author tll
 * @date 2023-10-12
 */
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/zhgd/asphaltCommon")
public class NAsphaltCommonController extends BaseController {

    private final NAsphaltCommonService nAsphaltCommonService;

    /**
     * 获取最新一条数据
     */
    @SaCheckLogin
    @GetMapping("/getLastData")
    public R<NAsphaltData> getLastData(@RequestParam Map<String, Object> params) {
        return R.ok(nAsphaltCommonService.getLastData(params));
    }

    /**
     * 获取最新数据日期
     * @param params
     * @return
     */
    @SaCheckLogin
    @GetMapping("/getLastDay")
    public R<String> getLastDay(@RequestParam Map<String, Object> params) {
        return R.ok("", nAsphaltCommonService.getLastDay(params));
    }

    /**
     * 获取最新数据月份
     * @param params
     * @return
     */
    @SaCheckLogin
    @GetMapping("/getLastMonth")
    public R<String> getLastMonth(@RequestParam Map<String, Object> params) {
        return R.ok("", nAsphaltCommonService.getLastMonth(params));
    }

    /**
     * 获取最新数据年份
     * @param params
     * @return
     */
    @SaCheckLogin
    @GetMapping("/getLastYear")
    public R<String> getLastYear(@RequestParam Map<String, Object> params) {
        return R.ok("", nAsphaltCommonService.getLastYear(params));
    }

    /**
     * 获取所有有生产数据的年份
     * @param params
     * @return
     */
    @SaCheckLogin
    @GetMapping("/getAllYear")
    public R<List<String>> getAllYear(@RequestParam Map<String, Object> params) {
        return R.ok(nAsphaltCommonService.getAllYear(params));
    }

}
